find most frequent element in an array javascript